import 'package:flutter/material.dart';

class MyApp2 extends StatelessWidget {
  // 2. 设置默认值
  const MyApp2({
    super.key,
    this.title = '',
    this.content = '',
    this.tColor = Colors.orange,
    this.cColor = Colors.yellow,
  });

  // 1. 定义属性
  final String title;
  final String content;
  final Color tColor;
  final Color cColor;

  // 重写build 返回需要封装的组件即可
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.purple,
            title: Center(
              child: Text(
                '标题为:$title',
                style: TextStyle(
                    color: tColor, fontSize: 30, fontWeight: FontWeight.w900),
              ),
            ),
          ),
          // 1.2 主体部分
          body: Center(
            // 3.子组件 Text 文本
            child: Text(
              // 内容
              '内容为:$content',
              // 文字方向
              textDirection: TextDirection.rtl,
              style: TextStyle(
                  color: cColor, fontSize: 40.5, fontWeight: FontWeight.w900),
            ),
          )),
    );
  }
}
